package com.atguigu.Controller;

import com.atguigu.Serivce.SetmealService;
import com.atguigu.Utils.R;
import com.atguigu.pojo.Category;
import com.atguigu.pojo.Dto.SetmealDto;
import com.atguigu.pojo.Setmeal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    @PostMapping
    public R addSetmeal(@RequestBody SetmealDto setmealDto) {
        return setmealService.addSetmeal(setmealDto);
    }

    @GetMapping("page")
    public R page(int page,int pageSize,String name){
        return setmealService.page(page,pageSize,name);
    }

    @DeleteMapping
    public R deleteSetmeal(Long[] ids) {
        return setmealService.remove(ids);
    }

    @PostMapping("status/{status}")//status是要修改为的状态
    public R updateSetmealStatus(@PathVariable("status")int status,Long[] ids) {
        return setmealService.updateSetmealState(status,ids);
    }

    @GetMapping("list")
    public R getSetmealList(Setmeal setmeal) {
        return setmealService.list(setmeal);
    }
}
